package Reeks5.VanRansbeeck.Kevin.View;

import Reeks5.VanRansbeeck.Kevin.Model.*;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.net.URL;
import java.util.Observable;
import java.util.Observer;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import sun.awt.VerticalBagLayout;

/** Paneel dat saldo van een speler toont **/

public class SaldoPlayerTile extends JPanel implements Observer {
    protected Speler speler;
    protected JLabel silhouette;
    protected JLabel naam;
    protected JLabel saldo;
    
    public SaldoPlayerTile(Speler speler) {
        super();
        
        Box b1;
        
        b1 = Box.createVerticalBox();
        
        this.setSize(78, 100);
        this.setSpeler(speler);
        URL imageLoc = ClassLoader.getSystemResource("images/silhouette.gif");
        this.silhouette = new JLabel(new ImageIcon(imageLoc), JLabel.CENTER);
        this.naam = new JLabel(speler.getNaam(), JLabel.CENTER);
        this.saldo = new JLabel("Saldo: " + speler.getSaldo(), JLabel.CENTER);
        
        b1.add(silhouette);
        b1.add(naam);
        b1.add(saldo);
        
        this.add(b1);
    }

    public JLabel getSaldo() {
        return saldo;
    }

    protected void setSaldo(JLabel saldo) {
        this.saldo = saldo;
    }

    public Speler getSpeler() {
        return speler;
    }

    protected void setSpeler(Speler speler) {
        this.speler = speler;
    }
    
    public void update(Observable o, Object o1) {
        this.saldo.setText("Saldo: " + this.getSpeler().getSaldo());
    }
    
}
